package loveATM.atm;


import loveATM.atm.Panel.*;

import javax.swing.*;
import java.awt.*;

/**
 * GUI版本的ATM
 */
public class ATM extends JFrame {
    private Image bgImg = new ImageIcon("images/background.jpg").getImage();
    private CardLayout cardLayout = new CardLayout();
    private LoginPanel loginPanel = new LoginPanel(this);
    private MenuPanel menuPanel = new MenuPanel(this);
    private SavePanel savePanel = new SavePanel(this);
    private GetPanel getPanel = new GetPanel(this);
    private SearchPanel searchPanel = new SearchPanel(this);
    private ChangePwdPanel changePwdPanel = new ChangePwdPanel(this);
    private TransferPanel transferPanel = new TransferPanel(this);



    public ATM(){
        this.setContentPane(new JPanel(){
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                g.drawImage(bgImg,0,0,this);
            }
        });
        this.setLayout(cardLayout);


        this.add(loginPanel,"login");
        this.add(menuPanel,"menu");
        this.add(savePanel,"save");
        this.add(getPanel,"get");
        this.add(searchPanel,"search");
        this.add(changePwdPanel,"changePwd");
        this.add(transferPanel,"transferBtn");

        this.setTitle("ATM");
        this.setSize(1024,768);
        this.setResizable(false);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setLocationRelativeTo(null);
        this.setVisible(true);
    }
    public void showPanel(String name){
        cardLayout.show(this.getContentPane(),name);
    }
    public static void main(String[] args) {
        new ATM();
    }
}
